import { constructMockData } from '@/mock/mock'
import { AxiosRequestConfig } from 'axios'
import { dayjs } from 'element-plus'
import Mock from 'mockjs'
/**
 * @description 用户分析-性别年龄学历分布数据
 */
export const genderAgeEducationInterfaceRes = (
  config: AxiosRequestConfig<any>,
) => {
  const { dateRange, type } = JSON.parse(config.data)
  // 计算需要多少天的数据
  const [startDate, endDate] = dateRange
  const diffDays = dayjs(endDate).diff(startDate, 'day') + 1
  // 生成数据
  const data = Array.from({
    length: (diffDays < 30 ? diffDays : 30) * Mock.Random.integer(3, 10),
  }).map(() => {
    return {
      type,
      // 性别
      gender: Mock.Random.integer(0, 1),
      // 年龄
      age: Mock.Random.integer(10, 80),
      // 学历
      educationType: Mock.Random.integer(0, 4),
    }
  })
  return constructMockData(data)
}
/**
 * @description 用户分析-兴趣指数数据
 */
export const interestIndexInterfaceRes = (config: AxiosRequestConfig<any>) => {
  const { dateRange, type } = JSON.parse(config.data)
  // 计算需要多少天的数据
  const [startDate, endDate] = dateRange
  // const diffDays = dayjs(endDate).diff(startDate, 'day') + 1
  interface Categories {
    [key: string]: string
  }
  const categories: Categories = {
    businessServices: '商务服务',
    jobSeekingAndEntrepreneurship: '求职创业',
    buildingMaterialsAndHomeFurnishings: '建材家居',
    realEstate: '房产',
    lifestyleServices: '生活服务',
    leisureActivities: '休闲爱好',
    financeAndEconomics: '金融财经',
    sportsAndFitness: '体育健身',
    clothingShoesAndBags: '服饰鞋包',
    flowersBirdsAndCutePets: '花鸟萌宠',
    personalCareAndBeauty: '个护美妆',
    maternityAndChildCare: '母婴亲子',
    homeAppliancesAndDigitalProducts: '家电数码',
    travelAndHotelAccommodations: '旅游酒店',
    foodAndDining: '餐饮美食',
    automobiles: '汽车',
    educationAndTraining: '教育培训',
    onlineShopping: '网络购物',
    medicalAndHealthcare: '医疗健康',
    consulting: '咨询',
    booksAndReading: '书籍阅读',
    gaming: '游戏',
    filmTelevisionAndEntertainment: '影视娱乐',
    softwareApplications: '软件应用',
  }

  const result = Object.keys(categories).map((key) => ({
    label: categories[key],
    value: Mock.Random.integer(0, 10),
  }))
  // 生成数据
  const data = {
    type,
    DateRange: [startDate, endDate],
    data: result,
  }
  return constructMockData(data)
}
/**
 * @description 用户分析-地域分布数据
 */
export const regionalDistributionRes = (config: AxiosRequestConfig<any>) => {
  const { dateRange, type } = JSON.parse(config.data)
  // 计算需要多少天的数据
  const [startDate, endDate] = dateRange
  // const diffDays = dayjs(endDate).diff(startDate, 'day') + 1

  const result = [
    {
      name: '江苏',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '北京',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '上海',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '重庆',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '河北',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '河南',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '云南',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '辽宁',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '黑龙江',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '湖南',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '安徽',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '山东',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '新疆',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '浙江',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '江西',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '湖北',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '广西',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '甘肃',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '山西',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '内蒙古',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '陕西',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '吉林',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '福建',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '贵州',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '广东',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '青海',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '西藏',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '四川',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '宁夏',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '海南',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '台湾',
      value: Mock.Random.integer(0, 100),
    },
    {
      name: '香港',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
    {
      name: '澳门',
      value: [
        Mock.Random.integer(0, 1000),
        Mock.Random.integer(0, 100),
        Mock.Random.integer(0, 100),
      ][Mock.Random.integer(0, 2)],
    },
  ]
  // 生成数据
  const data = {
    type,
    DateRange: [startDate, endDate],
    data: result,
  }
  return constructMockData(data)
}
/**
 * @description 用户分析-浏览器数据
 */
export const BrowserInterfaceRes = (config: AxiosRequestConfig<any>) => {
  const { dateRange, type } = JSON.parse(config.data)
  // 计算需要多少天的数据
  const [startDate, endDate] = dateRange
  // const diffDays = dayjs(endDate).diff(startDate, 'day') + 1

  const result = [
    {
      name: 'Chrome',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '360安全浏览器',
      value: Mock.Random.integer(0, 1000),
    },
    {
      name: 'Safari浏览器',
      value: Mock.Random.integer(0, 1000),
    },
    {
      name: '360极速浏览器',
      value: Mock.Random.integer(0, 1000),
    },
    {
      name: '火狐浏览器',
      value: Mock.Random.integer(0, 1000),
    },
    {
      name: 'QQ浏览器',
      value: Mock.Random.integer(0, 1000),
    },
    {
      name: '搜狗浏览器',
      value: Mock.Random.integer(0, 1000),
    },
    {
      name: 'UC浏览器',
      value: Mock.Random.integer(0, 1000),
    },
    {
      name: '其他',
      value: Mock.Random.integer(0, 50),
    },
  ]
  // 生成数据
  const data = {
    type,
    DateRange: [startDate, endDate],
    data: result,
  }
  return constructMockData(data)
}
/**
 * @description 用户分析-主要功能数据
 */
export const MainFeaturesRes = (config: AxiosRequestConfig<any>) => {
  const { dateRange, type } = JSON.parse(config.data)
  // 计算需要多少天的数据
  const [startDate, endDate] = dateRange
  // const diffDays = dayjs(endDate).diff(startDate, 'day') + 1

  const result = [
    {
      name: '市场概览-今日市场',
      value: Mock.Random.integer(5000, 10000),
    },
    {
      name: '概念机会-风口掘金',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '行业机会-黄金时代',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '投资前沿-趋势先锋',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '新兴机会-探索未来',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '热点追踪-关注焦点',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '趋势洞察-行情预测',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '投资方向-聚焦赛道',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '市场动态-时事解读',
      value: Mock.Random.integer(2000, 5000),
    },
    {
      name: '策略分析-投资思路',
      value: Mock.Random.integer(2000, 5000),
    },
  ]
  // 生成数据
  const data = {
    type,
    DateRange: [startDate, endDate],
    data: result,
  }
  return constructMockData(data)
}
/**
 * @description 用户分析-热门功能数据
 */
export const HotFeaturesRes = (config: AxiosRequestConfig<any>) => {
  const { dateRange, type } = JSON.parse(config.data)
  // 计算需要多少天的数据
  const [startDate, endDate] = dateRange
  // const diffDays = dayjs(endDate).diff(startDate, 'day') + 1

  const result = [
    {
      name: '市场概览-今日市场',
      value: Mock.Random.integer(5000, 10000),
    },
    {
      name: '概念机会-风口掘金',
      value: Mock.Random.integer(500, 3000),
    },
    {
      name: '行业机会-黄金时代',
      value: Mock.Random.integer(500, 5000),
    },
    {
      name: '投资前沿-趋势先锋',
      value: Mock.Random.integer(500, 5000),
    },
    {
      name: '新兴机会-探索未来',
      value: Mock.Random.integer(500, 5000),
    },
    {
      name: '热点追踪-关注焦点',
      value: Mock.Random.integer(500, 5000),
    },
    {
      name: '趋势洞察-行情预测',
      value: Mock.Random.integer(500, 5000),
    },
    {
      name: '投资方向-聚焦赛道',
      value: Mock.Random.integer(500, 5000),
    },
    {
      name: '市场动态-时事解读',
      value: Mock.Random.integer(500, 5000),
    },
    {
      name: '策略分析-投资思路',
      value: Mock.Random.integer(500, 5000),
    },
  ]
  // 生成数据
  const data = {
    type,
    DateRange: [startDate, endDate],
    data: result,
  }
  return constructMockData(data)
}
/**
 * @description 用户分析-页面分析数据
 */
export const PageAnalysisRes = (config: AxiosRequestConfig<any>) => {
  const { dateRange, type } = JSON.parse(config.data)
  // 计算需要多少天的数据
  const [startDate, endDate] = dateRange
  // const diffDays = dayjs(endDate).diff(startDate, 'day') + 1
  const pageList = [
    '首页',
    '交易中心',
    '行情分析',
    '资产管理',
    '股票查询',
    '基金产品',
    '债券市场',
    '期货交易',
    '外汇牌价',
    '黄金市场',
    '理财产品',
    '风险评估',
    '投资策略',
    '资讯中心',
    '投资者教育',
    'VIP服务',
    '在线客服',
  ]
  const result = pageList.map((item) => ({
    page: item,
    pv: Mock.Random.integer(5000, 10000),
    entranceCount: Mock.Random.integer(5000, 10000),
    downstreamPv: Mock.Random.integer(1000, 3000),
    exitCount: Mock.Random.integer(1000, 5000),
    avgVisitTime: Mock.Random.integer(30, 60 * 20),
  }))
  // 生成数据
  const data = {
    type,
    DateRange: [startDate, endDate],
    data: result,
  }
  return constructMockData(data)
}
